' A u t h o r :                 A l l e n   B r o w n e .       a l l e n @ a l l e n b r o w n e . c o m 
 
 ' D e v e l o p e r :           R e y n a l d o   O .   C o r v e r a .   p r o u d p i n o y 3 5 7 @ y a h o o . c o m 
 
 O p t i o n   C o m p a r e   D a t a b a s e 
 
 O p t i o n   E x p l i c i t 
 
 
 
 ' C o n f i g u r a t i o n   o p t i o n s 
 
 P r i v a t e   C o n s t   m b c S t a r t O f F i e l d   =   F a l s e       ' T r u e   t o   m a t c h   o n l y   t h e   s t a r t   o f   t h e   f i e l d ;   F a l s e   f o r   a n y w h e r e   i n   f i e l d . 
 
 P r i v a t e   C o n s t   m s t r c W i l d c a r d C h a r   =   " * "       ' P a t t e r n   m a t c h i n g   w i l d c a r d .   " * "   f o r   A c c e s s .   " % "   f o r   S Q L   S e r v e r . 
 
 P r i v a t e   C o n s t   m s t r c S e p   =   " ; "                         ' S e p a r a t o r   b e t w e e n   l i s t   i t e m s .   M a y   n e e d   c h a n g i n g   f o r   s o m e   r e g i o n a l   s e t t i n g s . 
 
 
 
 ' C o l u m n s   o f   c b o F i n d A s U T y p e F i e l d 
 
 P r i v a t e   C o n s t   m i c C o n t r o l N a m e   =   0 
 
 P r i v a t e   C o n s t   m i c C o n t r o l L a b e l   =   1 
 
 P r i v a t e   C o n s t   m i c C o n t r o l T y p e   =   2 
 
 P r i v a t e   C o n s t   m i c F i l t e r F i e l d   =   3 
 
 P r i v a t e   C o n s t   m i c F i e l d T y p e   =   4 
 
 
 
 ' C o n s t a n t   t o   i n d i c a t e   a   c o n t r o l   i s   s i t t i n g   o n   t h e   f o r m   ( n o t   o n   t h e   p a g e   o f   a   t a b   c o n t r o l . ) 
 
 P r i v a t e   C o n s t   m l n g c O n T h e F o r m   =   - 1 & 
 
 
 
 ' M o d u l e   n a m e   ( f o r   e r r o r   h a n d l e r . ) 
 
 P r i v a t e   C o n s t   c o n M o d   =   " g o o g l e M o d " 
 
 
 
 P u b l i c   F u n c t i o n   F i n d A s U T y p e L o a d ( f r m   A s   F o r m ,   P a r a m A r r a y   a v a r E x c e p t i o n L i s t ( ) )   A s   B o o l e a n 
 
 O n   E r r o r   G o T o   E r r _ H a n d l e r 
 
         ' P u r p o s e :       I n i t i a l i z e   t h e   c o d e   f o r   F i n d . 
 
         ' R e t u r n :         T r u e   o n   s u c c e s s . 
 
         ' A r g u m e n t s :   -   f r m   =   a   r e f e r e n c e   t o   t h e   f o r m   w h e r e   y o u   w a n t   t h i s   f i l t e r i n g . 
 
         '                       -   O p t i o n a l l y ,   y o u   c a n   s p e c i f y   c o n t r o l s   N O T   t o   o f f e r   f i l t e r i n g   o n ,   b y   p u t t i n g   t h e   c o n t r o l   n a m e s   i n   q u o t e s . 
 
         ' N o t e :             T h e   f o r m   m u s t   c o n t a i n   t h e   2   c o n t r o l s ,   c b o F i n d A s U T y p e F i e l d   a n d   t x t F i n d A s U T y p e V a l u e , 
 
         '                               w i t h   t h e   c o m b o   s e t   u p   c o r r e c t l y . 
 
         ' U s a g e :           S e t   t h e   L o a d   e v e n t   p r o c e d u r e   o f   t h e   f o r m   t o : 
 
         '                               C a l l   F i n d A s U T y p e ( M e ) 
 
         '                       T o   s u p p r e s s   f i l t e r i n g   o n   c o n t r o l s   F i r s t N a m e   a n d   C i t y ,   u s e : 
 
         '                               C a l l   F i n d A s U T y p e ( M e ,   " F i r s t N a m e " ,   " C i t y " ) 
 
         D i m   r s   A s   D A O . R e c o r d s e t                           ' C l o n e   s e t   o f   t h e   f o r m . 
 
         D i m   c t l   A s   C o n t r o l                                     ' E a c h   c o n t r o l   o n   t h e   f o r m . 
 
         D i m   s t r F o r m   A s   S t r i n g                               ' N a m e   o f   f o r m   ( f o r   e r r o r   h a n d l e r . ) 
 
         D i m   s t r C o n t r o l   A s   S t r i n g                         ' N a m e   o f   t h e   c o n t r o l . 
 
         D i m   s t r F i e l d   A s   S t r i n g                             ' N a m e   o f   t h e   f i l t e r   t o   u s e   i n   t h e   f i l t e r   s t r i n g . 
 
         D i m   s t r C o n t r o l S o u r c e   A s   S t r i n g             ' N a m e   o f   t h e   f i e l d   t h e   c o n t r o l   i s   b o u n d   t o . 
 
         D i m   s t r O u t   A s   S t r i n g                                 ' L i s t   f o r   t h e   R o w S o u r c e   o f   c b o F i n d A s U T y p e F i e l d . 
 
         D i m   l n g I   A s   L o n g                                         ' L o o p   c o u n t e r . 
 
         D i m   l n g J   A s   L o n g                                         ' P a g e   c o u n t e r   l o o p   c o n t r o l l e r . 
 
         D i m   b S k i p   A s   B o o l e a n                                 ' F l a g   t o   p r o v i d e   n o   f i l t e r i n g   f o r   t h i s   c o n t r o l . 
 
         D i m   b R e s u l t   A s   B o o l e a n                             ' R e t u r n   v a l u e   f o r   t h i s   f u n c t i o n . 
 
         D i m   l n g P a r e n t N u m b e r   A s   L o n g                   ' - 1   i f   t h e   c o n t r o l   i s   d i r e c t l y   o n   t h e   f o r m ,   e l s e   P a g e I n d e x   o f   i t   p a r e n t . 
 
         D i m   l n g M a x P a r e n t N u m b e r   A s   L o n g             ' P a g e I n d e x   o f   l a s t   p a g e   o f   t a b   c o n t r o l .   - 1   i f   n o   t a b   c o n t r o l . 
 
         D i m   a s t r C o n t r o l s ( )   A s   S t r i n g                 ' A r r a y   t o   h a n d l e   t h e   c o n t r o l s   o n   t h e   f o r m . 
 
         C o n s t   l n g c C o n t r o l   =   0 &                             ' F i r s t   e l e m e n t   o f   a r r a y   a s t r C o n t r o l s   i s   t h e   c o n t r o l   n a m e . 
 
         C o n s t   l n g c F i e l d   =   1 &                                 ' S e c o n d   e l e m e n t   o f   t h e   a r r a y   i s   t h e   f i e l d   n a m e   t o   f i l t e r   o n . 
 
         
 
         ' T h e   f o r m   m u s t   h a v e   a   c o n t r o l   s o u r c e   i f   w e   a r e   t o   f i l t e r   i t ,   a n d   n e e d s   o u r   3   c o n t r o l s . 
 
         s t r F o r m   =   f r m . N a m e 
 
         
 
         I f   H a s U n b o u n d C o n t r o l s ( f r m ,   " c b o F i n d A s U T y p e F i e l d " ,   " t x t F i n d A s U T y p e V a l u e " )   A n d   ( f r m . R e c o r d S o u r c e   < >   v b N u l l S t r i n g )   T h e n 
 
                 ' S e t   t h e   e v e n t   h a n d e r s   f o r   t h e   2   c o n t o r l s 
 
                 f r m ! c b o F i n d A s U T y p e F i e l d . A f t e r U p d a t e   =   " = F i n d A s U T y p e C h a n g e ( [ F o r m ] ) " 
 
                 f r m . t x t F i n d A s U T y p e V a l u e . O n C h a n g e   =   " = F i n d A s U T y p e C h a n g e ( [ F o r m ] ) " 
 
                 ' C a l c u l a t e   t h e   n u m b e r   o f   p a g e s   o n   t h e   t a b   c o n t r o l   i f   t h e r e   i s   o n e . 
 
                 l n g M a x P a r e n t N u m b e r   =   M a x P a r e n t N u m b e r ( f r m ) 
 
                 
 
                 ' D e c l a r e   a n   a r r a y   l a r g e   e n o u g h   t o   h a n d l e   t h e   c o n t r o l s   o n   t h e   f o r m , 
 
                 '       f o r   e a c h   p a g e   o f   a n y   t a b   c o n t r o l   ( s i n c e   t h e s e   h a v e   t h e i r   o w n   t a b   i n d e x ) , 
 
                 '       a n d   f o r   s t o r i n g   t h e   c o n t r o l   n a m e   a n d   t h e   f i l t e r   f i e l d   n a m e . 
 
                 R e D i m   a s t r C o n t r o l s ( 0 &   T o   f r m . C o n t r o l s . C o u n t   -   1 & ,   m l n g c O n T h e F o r m   T o   l n g M a x P a r e n t N u m b e r ,   l n g c C o n t r o l   T o   l n g c F i e l d )   A s   S t r i n g 
 
                 S e t   r s   =   f r m . R e c o r d s e t C l o n e                           ' F o r   i n f o   a b o u t   t h e   f i e l d s   t h e   c o n t r o l s   a r e   b o u n d   t o . 
 
                 
 
                 ' L o o p   t h r o u g h   t h e   c o n t r o l s   o n   t h e   f o r m . 
 
                 F o r   E a c h   c t l   I n   f r m . C o n t r o l s 
 
                         ' I g n o r e   h i d d e n   c o n t r o l s ,   a n d   l i m i t   o u r s e l v e s   t o   t e x t   b o x e s   a n d   c o m b o s . 
 
                         I f   c t l . V i s i b l e   T h e n 
 
                                 I f   ( c t l . C o n t r o l T y p e   =   a c T e x t B o x )   O r   ( c t l . C o n t r o l T y p e   =   a c C o m b o B o x )   T h e n 
 
                                         b S k i p   =   F a l s e 
 
                                         s t r F i e l d   =   v b N u l l S t r i n g 
 
                                         s t r C o n t r o l   =   c t l . N a m e 
 
                                         ' I g n o r e   i f   t h e   c o n t r o l   n a m e   i s   i n   t h e   e x c e p t i o n   l i s t . 
 
                                         F o r   l n g I   =   L B o u n d ( a v a r E x c e p t i o n L i s t )   T o   U B o u n d ( a v a r E x c e p t i o n L i s t ) 
 
                                                 I f   a v a r E x c e p t i o n L i s t ( l n g I )   =   s t r C o n t r o l   T h e n 
 
                                                         b S k i p   =   T r u e 
 
                                                         E x i t   F o r 
 
                                                 E n d   I f 
 
                                         N e x t 
 
                                         
 
                                         I f   N o t   b S k i p   T h e n 
 
                                                 ' I g n o r e   i f   u n b o u n d ,   o r   b o u n d   t o   a n   e x p r e s s i o n . 
 
                                                 s t r C o n t r o l S o u r c e   =   c t l . C o n t r o l S o u r c e 
 
                                                 I f   ( s t r C o n t r o l S o u r c e   =   v b N u l l S t r i n g )   O r   ( s t r C o n t r o l S o u r c e   L i k e   " = * " )   T h e n 
 
                                                         b S k i p   =   T r u e 
 
                                                 E l s e 
 
                                                         ' I g n o r e   y e s / n o   f i e l d s ,   b i n a r y   ( J E T   u s e s   f o r   u n k n o w n ) ,   a n d   c o m p l e x   d a t a   t y p e s   ( >   1 0 0 . ) 
 
                                                         S e l e c t   C a s e   r s ( s t r C o n t r o l S o u r c e ) . T y p e 
 
                                                         C a s e   d b B o o l e a n ,   d b L o n g B i n a r y ,   d b B i n a r y ,   d b G U I D ,   I s   >   1 0 0 
 
                                                                 b S k i p   =   T r u e 
 
                                                         E n d   S e l e c t 
 
                                                 E n d   I f 
 
                                         E n d   I f 
 
                                         
 
                                         ' I g n o r e   i f   w e   c a n n o t   s p e c i f y   t h e   f i e l d   t o   f i l t e r   o n . 
 
                                         I f   N o t   b S k i p   T h e n 
 
                                                 s t r F i e l d   =   G e t F i l t e r F i e l d ( c t l ) 
 
                                                 I f   s t r F i e l d   =   v b N u l l S t r i n g   T h e n 
 
                                                         b S k i p   =   T r u e 
 
                                                 E n d   I f 
 
                                         E n d   I f 
 
                                         
 
                                         ' A d d   t h i s   c o n t r o l   n a m e   t o   o u r   a r r a y ,   i n   t h e   o r d e r   o f   t h e   t a b   i n d e x . 
 
                                         I f   N o t   b S k i p   T h e n 
 
                                                 l n g P a r e n t N u m b e r   =   P a r e n t N u m b e r ( c t l ) 
 
                                                 a s t r C o n t r o l s ( c t l . T a b I n d e x ,   l n g P a r e n t N u m b e r ,   l n g c C o n t r o l )   =   s t r C o n t r o l 
 
                                                 a s t r C o n t r o l s ( c t l . T a b I n d e x ,   l n g P a r e n t N u m b e r ,   l n g c F i e l d )   =   s t r F i e l d 
 
                                         E n d   I f 
 
                                 E n d   I f 
 
                         E n d   I f 
 
                 N e x t 
 
                 
 
                 ' L o o p   t h r o u g h   t h e   a r r a y   o f   c o n t r o l s ,   t o   b u i l d   t h e   s t r i n g   f o r   t h e   R o w S o u r c e   o f   c b o F i n d A s U T y p e F i e l d   ( 5   c o l u m n s . ) 
 
                 F o r   l n g J   =   L B o u n d ( a s t r C o n t r o l s ,   2 )   T o   U B o u n d ( a s t r C o n t r o l s ,   2 ) 
 
                         F o r   l n g I   =   L B o u n d ( a s t r C o n t r o l s )   T o   U B o u n d ( a s t r C o n t r o l s ) 
 
                                 I f   a s t r C o n t r o l s ( l n g I ,   l n g J ,   l n g c C o n t r o l )   < >   v b N u l l S t r i n g   T h e n 
 
                                         S e t   c t l   =   f r m . C o n t r o l s ( a s t r C o n t r o l s ( l n g I ,   l n g J ,   l n g c C o n t r o l ) ) 
 
                                         s t r O u t   =   s t r O u t   &   " " " "   &   c t l . N a m e   &   " " " "   &   m s t r c S e p   &   _ 
 
                                                 " " " "   &   C a p t i o n 4 C o n t r o l ( f r m ,   c t l )   &   " " " "   &   m s t r c S e p   &   _ 
 
                                                 c t l . C o n t r o l T y p e   &   m s t r c S e p   &   _ 
 
                                                 " " " "   &   a s t r C o n t r o l s ( l n g I ,   l n g J ,   l n g c F i e l d )   &   " " " "   &   m s t r c S e p   &   _ 
 
                                                 " " " "   &   r s ( c t l . C o n t r o l S o u r c e ) . T y p e   &   " " " "   &   m s t r c S e p 
 
                                 E n d   I f 
 
                         N e x t 
 
                 N e x t 
 
                 r s . C l o s e 
 
                 
 
                 ' R e m o v e   t h e   t r a i l i n g   s e p a r a t o r ,   a n d   a s s i g n   t o   t h e   R o w S o u r c e   o f   c b o F i n d A s U T y p e F i e l d . 
 
                 l n g I   =   L e n ( s t r O u t )   -   L e n ( m s t r c S e p ) 
 
                 I f   l n g I   >   0   T h e n 
 
                         W i t h   f r m . c b o F i n d A s U T y p e F i e l d 
 
                                 . R o w S o u r c e   =   L e f t ( s t r O u t ,   l n g I ) 
 
                                 . V a l u e   =   . I t e m D a t a ( 0 )                       ' I n i t i a l i z e   t o   t h e   f i r s t   i t e m   i n   t h e   l i s t . 
 
                         E n d   W i t h 
 
                         b R e s u l t   =   T r u e                         ' R e t u r n   T r u e :   t h e   l i s t   l o a d e d   s u c c e s s f u l l y . 
 
                 E n d   I f 
 
         E n d   I f 
 
         
 
         ' S h o w   t h e   f i l t e r   c o n t r o l s .   ( S e p a r a t e   r o u t i n e ,   s i n c e   t h e y   c o u l d   f a i l   i f   t h e   c o n t r o l   d o e s   n o t   e x i s t . ) 
 
         C a l l   S h o w H i d e C o n t r o l ( f r m ,   " c b o F i n d A s U T y p e F i e l d " ,   b R e s u l t ) 
 
         C a l l   S h o w H i d e C o n t r o l ( f r m ,   " t x t F i n d A s U T y p e V a l u e " ,   b R e s u l t ) 
 
         
 
         ' R e t u r n   v a l u e 
 
         F i n d A s U T y p e L o a d   =   b R e s u l t 
 
 
 
 E x i t _ H a n d l e r : 
 
         S e t   c t l   =   N o t h i n g 
 
         S e t   r s   =   N o t h i n g 
 
         E x i t   F u n c t i o n 
 
 
 
 E r r _ H a n d l e r : 
 
         C a l l   L o g E r r o r ( E r r . N u m b e r ,   E r r . D e s c r i p t i o n ,   c o n M o d   &   " . F i n d A s U T y p e L o a d " ,   " F o r m   "   &   s t r F o r m ) 
 
         R e s u m e   E x i t _ H a n d l e r 
 
 E n d   F u n c t i o n 
 
 
 
 P u b l i c   F u n c t i o n   F i n d A s U T y p e C h a n g e ( f r m   A s   F o r m )   A s   B o o l e a n 
 
 O n   E r r o r   G o T o   E r r _ H a n d l e r 
 
         ' P u r p o s e :       F i l t e r   t h e   f o r m ,   b y   t h e   c o n t r o l   n a m e d   i n   c b o F i n d A s U T y p e F i e l d   a n d   t h e   v a l u e   i n   t x t F i n d A s U T y p e V a l u e . 
 
         ' R e t u r n :         T r u e   u n l e s s   a n   e r r o r   o c c u r r e d . 
 
         ' U s a g e :           T h e   c o d e   a s s i g n s   t h i s   t o   t h e   C h a n g e   e v e n t   o f   t h e   t e x t   b o x ,   a n d   t h e   A f t e r U p d a t e   e v e n t   o f   t h e   c o m b o . 
 
         D i m   s t r T e x t   A s   S t r i n g               ' T h e   t e x t   o f   t h e   t e x t   b o x . 
 
         D i m   l n g S e l S t a r t   A s   L o n g           ' S e l e c t i o n   S t a r t i n g   p o i n t . 
 
         D i m   s t r F i e l d   A s   S t r i n g             ' N a m e   o f   t h e   f i e l d   t o   f i l t e r   o n . 
 
         D i m   b H a s F o c u s   A s   B o o l e a n         ' T r u e   i f   t h e   t e x t   b o x   h a s   f o c u s   ( s i n c e   i t   c a n   b e   c a l l e d   f r o m   t h e   c o m b o   t o o . ) 
 
         C o n s t   s t r c T e x t B o x   =   " t x t F i n d A s U T y p e V a l u e " 
 
 
 
         ' I f   t h e   t e x t   b o x   h a s   f o c u s ,   r e m e m b e r   t h e   s e l e c t i o n   i n s e r t   p o i n t   a n d   u s e   i t s   T e x t .   O t h e r w i s e   u s e   i t s   V a l u e . 
 
         b H a s F o c u s   =   ( f r m . A c t i v e C o n t r o l . N a m e   =   s t r c T e x t B o x ) 
 
         I f   b H a s F o c u s   T h e n 
 
                 s t r T e x t   =   f r m ! t x t F i n d A s U T y p e V a l u e . T e x t 
 
                 l n g S e l S t a r t   =   f r m ! t x t F i n d A s U T y p e V a l u e . S e l S t a r t 
 
         E l s e 
 
                 s t r T e x t   =   N z ( f r m ! t x t F i n d A s U T y p e V a l u e . V a l u e ,   v b N u l l S t r i n g ) 
 
         E n d   I f 
 
         
 
         ' S a v e   a n y   u n c o m m i t t e d   e d i t s   i n   t h e   f o r m .   ( T h i s   l o s e s   t h e   i n s e r t i o n   p o i n t ,   a n d   c o n v e r t s   T e x t   t o   V a l u e . ) 
 
         I f   f r m . D i r t y   T h e n 
 
                 f r m . D i r t y   =   F a l s e 
 
         E n d   I f 
 
         
 
         ' R e a d   t h e   f i l t e r   f i e l d   n a m e   f r o m   t h e   c o m b o . 
 
         s t r F i e l d   =   N z ( f r m . c b o F i n d A s U T y p e F i e l d . C o l u m n ( m i c F i l t e r F i e l d ) ,   v b N u l l S t r i n g ) 
 
         
 
         ' U n f i l t e r   i f   t h e r e   i s   n o   t e x t   t o   f i n d ,   o r   n o   c o n t r o l   t o   f i l t e r .   O t h e r w i s e ,   f i l t e r . 
 
         I f   ( s t r T e x t   =   v b N u l l S t r i n g )   O r   ( s t r F i e l d   =   v b N u l l S t r i n g )   T h e n 
 
                 f r m . F i l t e r O n   =   F a l s e 
 
         E l s e 
 
                 f r m . F i l t e r   =   s t r F i e l d   &   "   L i k e   " " "   &   I I f ( m b c S t a r t O f F i e l d ,   v b N u l l S t r i n g ,   m s t r c W i l d c a r d C h a r )   &   _ 
 
                         s t r T e x t   &   m s t r c W i l d c a r d C h a r   &   " " " " 
 
                 f r m . F i l t e r O n   =   T r u e 
 
         E n d   I f 
 
         
 
         ' I f   t h e   c o n t r o l   h a d   f o c u s ,   r e s t o r e   f o c u s   i f   n e c e s s a r y ,   a n d   s e t   t h e   i n s e r t i o n   p o i n t . 
 
         I f   b H a s F o c u s   T h e n 
 
                 I f   f r m . A c t i v e C o n t r o l . N a m e   < >   s t r c T e x t B o x   T h e n 
 
                         f r m ( s t r c T e x t B o x ) . S e t F o c u s 
 
                 E n d   I f 
 
                 I f   s t r T e x t   < >   v b N u l l S t r i n g   T h e n 
 
                         f r m ! t x t F i n d A s U T y p e V a l u e   =   s t r T e x t 
 
                         f r m ! t x t F i n d A s U T y p e V a l u e . S e l S t a r t   =   l n g S e l S t a r t 
 
                 E n d   I f 
 
         E n d   I f 
 
         
 
         ' R e t u r n   T r u e   i f   t h e   r o u t i n e   c o m p l e t e d   w i t h o u t   e r r o r . 
 
         F i n d A s U T y p e C h a n g e   =   T r u e 
 
 
 
 E x i t _ H a n d l e r : 
 
         E x i t   F u n c t i o n 
 
 
 
 E r r _ H a n d l e r : 
 
         S e l e c t   C a s e   E r r . N u m b e r 
 
         C a s e   2 4 7 4 
 
                 R e s u m e   N e x t 
 
         C a s e   2 1 8 5       ' T e x t   b o x   l o s e s   f o c u s   w h e n   n o   c h a r a c t e r s   l e f t . 
 
                 R e s u m e   E x i t _ H a n d l e r 
 
         C a s e   E l s e 
 
                 M s g B o x   " E r r o r   "   &   E r r . N u m b e r   &   " :   "   &   E r r . D e s c r i p t i o n ,   v b E x c l a m a t i o n ,   " t x t F i n d A s U T y p e V a l u e _ C h a n g e " 
 
                 R e s u m e   E x i t _ H a n d l e r 
 
         E n d   S e l e c t 
 
 E n d   F u n c t i o n 
 
 
 
 P r i v a t e   F u n c t i o n   C a p t i o n 4 C o n t r o l ( f r m   A s   F o r m ,   c t l   A s   C o n t r o l )   A s   S t r i n g 
 
 O n   E r r o r   G o T o   E r r _ H a n d l e r 
 
         ' P u r p o s e : 
 
         D i m   s t r C a p t i o n   A s   S t r i n g 
 
 
 
         ' 1 s t   c h o i c e :   A s s i g n   t h e   c a p t i o n   o f   t h e   a t t a c h e d   l a b e l . 
 
         s t r C a p t i o n   =   c t l . C o n t r o l s ( 0 ) . C a p t i o n 
 
         
 
         ' 2 n d   c h o i c e :   R e a d   t h e   c a p t i o n   f r o m   t h e   l a b e l   o v e r   t h e   c o l u m n   i n   a   c o n t i n u o u s   f o r m . 
 
         I f   s t r C a p t i o n   =   v b N u l l S t r i n g   T h e n 
 
                 s t r C a p t i o n   =   C a p t i o n F r o m H e a d e r ( f r m ,   c t l ) 
 
         E n d   I f 
 
         
 
         ' S t r i p   t h e   t r a i l i n g   s e m i c o l o n . 
 
         I f   R i g h t $ ( s t r C a p t i o n ,   1 & )   =   " : "   T h e n 
 
                 s t r C a p t i o n   =   L e f t $ ( s t r C a p t i o n ,   L e n ( s t r C a p t i o n )   -   1 & ) 
 
         E n d   I f 
 
         ' S t r i p   t h e   a m p e r s a n d   h o t k e y . 
 
         I f   I n S t r ( s t r C a p t i o n ,   " & " )   >   0 &   T h e n 
 
                 s t r C a p t i o n   =   R e p l a c e ( s t r C a p t i o n ,   " & & " ,   C h r $ ( 3 1 ) ) 
 
                 s t r C a p t i o n   =   R e p l a c e ( s t r C a p t i o n ,   " & " ,   v b N u l l S t r i n g ) 
 
                 s t r C a p t i o n   =   R e p l a c e ( s t r C a p t i o n ,   C h r $ ( 3 1 ) ,   " & " ) 
 
         E n d   I f 
 
         
 
         ' 3 r d   c h o i c e :   U s e   t h e   c o n t r o l   n a m e . 
 
         I f   s t r C a p t i o n   =   v b N u l l S t r i n g   T h e n 
 
                 s t r C a p t i o n   =   c t l . N a m e 
 
         E n d   I f 
 
         
 
         C a p t i o n 4 C o n t r o l   =   s t r C a p t i o n 
 
         
 
 E x i t _ H a n d l e r : 
 
         E x i t   F u n c t i o n 
 
 
 
 E r r _ H a n d l e r : 
 
         S e l e c t   C a s e   E r r . N u m b e r 
 
         C a s e   2 4 6 7 & 
 
                 R e s u m e   N e x t 
 
         C a s e   E l s e 
 
                 M s g B o x   " E r r o r   "   &   E r r . N u m b e r   &   " :   "   &   E r r . D e s c r i p t i o n ,   v b E x c l a m a t i o n ,   " C a p t i o n 4 C o n t r o l ( ) " 
 
                 R e s u m e   E x i t _ H a n d l e r 
 
         E n d   S e l e c t 
 
 E n d   F u n c t i o n 
 
 
 
 P r i v a t e   F u n c t i o n   C a p t i o n F r o m H e a d e r ( f r m   A s   F o r m ,   c t l   A s   C o n t r o l )   A s   S t r i n g 
 
 O n   E r r o r   G o T o   E r r _ H a n d l e r 
 
         ' P u r p o s e :       L o o k   f o r   a   l a b e l   i n   t h e   c o l u m n   h e a d e r ,   d i r e c t l y   o v e r   t h e   c o n t r o l ,   i n   c o n t i n u o u s   f o r m   v i e w . 
 
         ' R e t u r n :         C a p t i o n   o f   t h e   l a b e l   i f   f o u n d . 
 
         D i m   c t l H e a d e r   A s   C o n t r o l         ' c o n t r o l s   i n   t h e   h e a d e r   o f   t h e   f o r m . 
 
         C o n s t   i c R a d i u s   =   1 2 0                 ' o n e   t w e l v e t h   o f   a n   i n c h ,   i n   t w i p s . 
 
         
 
         ' I f   w e   a r e   i n   F o r m   v i e w ,   a n d   i t ' s   a   C o n t i n u o u s   F o r m , 
 
         '       a n d   t h e r e   i s   a   l a b e l   i n   t h e   F o r m   H e a d e r   d i r e c t l y   a b o v e   t h e   c o l u m n ,   r e t u r n   i t s   C a p t i o n . 
 
         I f   ( f r m . C u r r e n t V i e w   =   1 )   A n d   ( f r m . D e f a u l t V i e w   =   1 )   T h e n 
 
                 F o r   E a c h   c t l H e a d e r   I n   f r m . S e c t i o n ( a c H e a d e r ) . C o n t r o l s 
 
                         I f   c t l H e a d e r . C o n t r o l T y p e   =   a c L a b e l   T h e n 
 
                                 I f   ( c t l H e a d e r . L e f t   >   c t l . L e f t   -   i c R a d i u s )   A n d   ( c t l H e a d e r . L e f t   <   c t l . L e f t   +   i c R a d i u s )   T h e n 
 
                                         C a p t i o n F r o m H e a d e r   =   c t l H e a d e r . C a p t i o n 
 
                                 E n d   I f 
 
                         E n d   I f 
 
                 N e x t 
 
         E n d   I f 
 
         
 
 E x i t _ H a n d l e r : 
 
         S e t   c t l H e a d e r   =   N o t h i n g 
 
         E x i t   F u n c t i o n 
 
 
 
 E r r _ H a n d l e r : 
 
         I f   E r r . N u m b e r   < >   2 4 6 2 &   T h e n           ' N o   s u c h   S e c t i o n . 
 
                 C a l l   L o g E r r o r ( E r r . N u m b e r ,   E r r . D e s c r i p t i o n ,   c o n M o d   &   " . C a p t i o n F r o m H e a d e r " ) 
 
         E n d   I f 
 
         R e s u m e   E x i t _ H a n d l e r 
 
 E n d   F u n c t i o n 
 
 
 
 P r i v a t e   F u n c t i o n   H a s U n b o u n d C o n t r o l s ( f r m   A s   F o r m ,   P a r a m A r r a y   a v a r C o n t r o l N a m e s ( ) )   A s   B o o l e a n 
 
 O n   E r r o r   G o T o   E r r _ H a n d l e r 
 
         ' P u r p o s e :       R e t u r n   t r u e   i f   a l l   t h e   c o n t r o l s   n a m e d   i n   t h e   a r r a y   a r e   p r e s e n t   o n   t h e   f o r m ,   a n d   a r e   u n b o u n d . 
 
         D i m   l n g I   A s   L o n g 
 
         D i m   b C a n c e l   A s   B o o l e a n 
 
         
 
         I f   U B o u n d ( a v a r C o n t r o l N a m e s )   >   0 &   T h e n 
 
                 ' L o o p   t h r o u g h   t h e   n a m e d   c o n t r o l s   o n   t h e   f o r m . 
 
                 F o r   l n g I   =   L B o u n d ( a v a r C o n t r o l N a m e s )   T o   U B o u n d ( a v a r C o n t r o l N a m e s ) 
 
                         I f   f r m . C o n t r o l s ( a v a r C o n t r o l N a m e s ( l n g I ) ) . C o n t r o l S o u r c e   < >   v b N u l l S t r i n g   T h e n 
 
                                 b C a n c e l   =   T r u e 
 
                                 E x i t   F o r 
 
                         E n d   I f 
 
                 N e x t 
 
                 ' I f   w e   d i d   n o t   d r o p   t o   t h e   e r r o r   h a n d l e r ,   t h e   f o r m   h a s   t h e   n a m e d   c o n t r o l s . 
 
                 H a s U n b o u n d C o n t r o l s   =   N o t   b C a n c e l 
 
         E n d   I f 
 
         
 
 E x i t _ H a n d l e r : 
 
         E x i t   F u n c t i o n 
 
 
 
 E r r _ H a n d l e r : 
 
         R e s u m e   E x i t _ H a n d l e r 
 
 E n d   F u n c t i o n 
 
 
 
 P r i v a t e   F u n c t i o n   M a x P a r e n t N u m b e r ( f r m   A s   F o r m )   A s   L o n g 
 
 O n   E r r o r   G o T o   E r r _ H a n d l e r 
 
         ' P u r p o s e :       R e t u r n   t h e   P a g e I n d e x   o f   t h e   t a b   p a g e   t h a t   t h e   c o n t r o l   i s   o n . 
 
         ' R e t u r n :         - 1   i f   s e t t i n g   d i r e c t l y   o n   t h e   f o r m ,   e l s e   t h e   P a g e I n d e x   o f   t h e   l a s t   p a g e   o f   t h e   t a b   c o n t r o l . 
 
         ' N o t e :             P a g e I n d e x   i s   z e r o   b a s e d ,   s o   s u b t r a c t   1   f r o m   t h e   c o u n t   o f   p a g e s . 
 
         D i m   c t l   A s   C o n t r o l                     ' E a c h   c o n t r o l   o n   t h e   f o r m . 
 
         D i m   l n g R e t u r n   A s   L o n g 
 
         
 
         l n g R e t u r n   =   m l n g c O n T h e F o r m             ' I n i t i a l i z e   t o   n o   t a b   c o n t r o l . 
 
         F o r   E a c h   c t l   I n   f r m . C o n t r o l s 
 
                 I f   c t l . C o n t r o l T y p e   =   a c T a b C t l   T h e n 
 
                         l n g R e t u r n   =   c t l . P a g e s . C o u n t   -   1 
 
                         E x i t   F o r                                         ' A   f o r m   c a n   h a v e   o n l y   o n e   t a b   c o n t r o l . 
 
                 E n d   I f 
 
         N e x t 
 
         
 
         M a x P a r e n t N u m b e r   =   l n g R e t u r n 
 
         
 
 E x i t _ H a n d l e r : 
 
         E x i t   F u n c t i o n 
 
 
 
 E r r _ H a n d l e r : 
 
         C a l l   L o g E r r o r ( E r r . N u m b e r ,   E r r . D e s c r i p t i o n ,   c o n M o d   &   " . M a x P a r e n t N u m b e r " ) 
 
         R e s u m e   E x i t _ H a n d l e r 
 
 E n d   F u n c t i o n 
 
 
 
 P r i v a t e   F u n c t i o n   P a r e n t N u m b e r ( c t l   A s   C o n t r o l )   A s   I n t e g e r 
 
 O n   E r r o r   R e s u m e   N e x t 
 
         ' P u r p o s e :       R e t u r n   t h e   P a g e I n d e x   o f   t h e   t a b   p a g e   t h a t   t h e   c o n t r o l   i s   o n . 
 
         ' R e t u r n :         - 1   i f   s e t t i n g   d i r e c t l y   o n   t h e   f o r m ,   e l s e   t h e   p a g e   o f   t h e   t a b   c o n t r o l . 
 
         ' N o t e :             T h i s   w o r k s   f o r   t e x t   b o x e s   a n d   c o m b o s ,   n o t   f o r   l a b e l s   o r   c o n t r o l s   i n   a n   o p t i o n   g r o u p . 
 
         D i m   i R e t u r n   A s   I n t e g e r 
 
         
 
         i R e t u r n   =   c t l . P a r e n t . P a g e I n d e x 
 
         I f   E r r . N u m b e r   < >   0 &   T h e n 
 
                 i R e t u r n   =   m l n g c O n T h e F o r m 
 
         E n d   I f 
 
         P a r e n t N u m b e r   =   i R e t u r n 
 
 E n d   F u n c t i o n 
 
 
 
 P r i v a t e   F u n c t i o n   S h o w H i d e C o n t r o l ( f r m   A s   F o r m ,   s t r C o n t r o l N a m e   A s   S t r i n g ,   b S h o w   A s   B o o l e a n )   A s   B o o l e a n 
 
 O n   E r r o r   R e s u m e   N e x t 
 
         ' P u r p o s e :       S h o w   o r   h i d e   a   c o n t r o l   o n   t h e   f o r m ,   w i t h o u t   e r r o r   m e s s a g e . 
 
         ' R e t u r n :         T r u e   i f   t h e   c o n t o r l ' s   V i s i b l e   p r o p e r t y   w a s   s e t   s u c c e s s f u l l y . 
 
         ' A r g u m e n t s :   f r m                         =   a   r e f e r e n c e   t o   t h e   f o r m   w h e r e   t h e   c o n t r o l   i s   e x p e c t e d . 
 
         '                       s t r C o n t r o l N a m e   =   t h e   n a m e   o f   t h e   c o n t r o l   t o   s h o w   o r   h i d e . 
 
         '                       b S h o w                     =   T r u e   t o   m a k e   v i s i b l e ;   F a l s e   t o   m a k e   i n v i s i b l e . 
 
         ' N o t e :             T h i s   i s   a   s e p a r a t e   r o u t i n e ,   s i n c e   h i d i n g   a   n o n - e x i s t a n t   c o n t r o l   w i l l   e r r o r . 
 
         f r m . C o n t r o l s ( s t r C o n t r o l N a m e ) . V i s i b l e   =   b S h o w 
 
         S h o w H i d e C o n t r o l   =   ( E r r . N u m b e r   =   0 & ) 
 
 E n d   F u n c t i o n 
 
 
 
 P r i v a t e   F u n c t i o n   G e t F i l t e r F i e l d ( c t l   A s   C o n t r o l )   A s   S t r i n g 
 
 O n   E r r o r   G o T o   E r r _ H a n d l e r 
 
         ' P u r p o s e :       D e t e r m i n e   t h e   f i e l d   n a m e   t o   u s e   w h e n   f i l t e r i n g   o n   t h i s   c o n t r o l . 
 
         ' R e t u r n :         T h e   f i e l d   n a m e   t h e   c o n t r o l   i s   b o u n d   t o ,   e x c e p t   f o r   c o m b o s . 
 
         '                               I n   A c c e s s   2 0 0 2   a n d   l a t e r ,   w e   r e t u r n   t h e   s y n t a x   A c c e s s   u s e s   f o r   f i l t e r i n g   t h e s e   c o n t r o l s . 
 
         ' A r g u m e n t :     T h e   c o n t r o l   w e   a r e   t r y i n g   t o   f i l t e r . 
 
         ' N o t e :             W e   d o n ' t   u s e   t h e   R e c o r d s e t   o f   t h e   c o m b o ,   b e c a u s e : 
 
         '                               a )   i t ' s   n o t   s u p p o r t e d   e a r l i e r   t h a n   A c c e s s   2 0 0 2 ,   a n d 
 
         '                               b )   i t ' s   o f t e n   n o t   l o a d e d   a t   t h i s   p o i n t . 
 
         '                               I n s t e a d ,   w e   O p e n R e c o r d s e t   t o   g e t   t h e   s o u r c e   f i e l d   n a m e , 
 
         '                               w h i c h   w o r k s   e v e n   i f   t h e   f i e l d   i s   a l i a s e d   i n   t h e   R o w S o u r c e . 
 
         '                               O p e n i n g   f o r   a p p e n d   o n l y   i s   q u i c k e r ,   a s   i t   l o a d s   n o   e x i s t i n g   r e c o r d s . 
 
         D i m   r s   A s   D A O . R e c o r d s e t           ' T o   g e t   i n f o r m a t i o n   a b o u t   t h e   c o m b o ' s   R o w S o u r c e . 
 
         D i m   i C o l u m n   A s   I n t e g e r             ' T h e   f i r s t   v i s i b l e   c o l u m n   o f   t h e   c o m b o   ( z e r o - b a s e d . ) 
 
         D i m   s t r F i e l d   A s   S t r i n g             ' R e t u r n   v a l u e :   t h e   f i e l d   n a m e   t o   u s e   f o r   t h e   f i l t e r   s t r i n g . 
 
         D i m   b C a n c e l   A s   B o o l e a n             ' F l a g   t o   n o t   f i l t e r   o n   t h i s   c o n t r o l . 
 
         
 
         I f   c t l . C o n t r o l T y p e   =   a c C o m b o B o x   T h e n 
 
                 i C o l u m n   =   F i r s t V i s i b l e C o l u m n ( c t l ) 
 
                 I f   i C o l u m n   =   c t l . B o u n d C o l u m n   -   1   T h e n 
 
                         ' T h e   b o u n d   c o l u m n   i s   t h e   f i r s t   v i s i b l e   c o l u m n :   f i l t e r   o n   t h e   c o n t r o l   s o u r c e   f i e l d . 
 
                         s t r F i e l d   =   " [ "   &   c t l . C o n t r o l S o u r c e   &   " ] " 
 
                 E l s e 
 
                         ' I n   A c c e s s   2 0 0 2   a n d   l a t e r ,   w e   c a n   u s e   t h e   l o o k u p   s y n t a x   A c c e s s   u s e s ,   i f   t h e   s o u r c e   i s   a   T a b l e / Q u e r y . 
 
                         I f   I n t ( V a l ( S y s C m d ( a c S y s C m d A c c e s s V e r ) ) )   > =   1 0   T h e n 
 
                                 I f   c t l . R o w S o u r c e T y p e   =   " T a b l e / Q u e r y "   T h e n 
 
                                         S e t   r s   =   D B E n g i n e ( 0 ) ( 0 ) . O p e n R e c o r d s e t ( c t l . R o w S o u r c e ,   d b O p e n D y n a s e t ,   d b A p p e n d O n l y ) 
 
                                         W i t h   r s . F i e l d s ( i C o l u m n ) 
 
                                                 s t r F i e l d   =   " [ L o o k u p _ "   &   c t l . N a m e   &   " ] . [ "   &   . S o u r c e F i e l d   &   " ] " 
 
                                         E n d   W i t h 
 
                                         r s . C l o s e 
 
                                 E l s e 
 
                                         b C a n c e l   =   T r u e     ' H i d d e n   b o u n d   c o l u m n   n o t   s u p p o r t e d   i f   R o w S o u r c e T y p e   i s   V a l u e   L i s t   o r   c a l l - b a c k   f u n c t i o n . 
 
                                 E n d   I f 
 
                         E l s e 
 
                                 b C a n c e l   =   T r u e             ' H i d d e n   b o u n d   c o l u m n   n o t   s u p p o r t e d   f o r   v e r s i o n s   e a r l i e r   t h a n   A c c e s s   2 0 0 2 . 
 
                         E n d   I f 
 
                 E n d   I f 
 
         E l s e 
 
                 ' N o t   a   c o m b o :   f i l t e r   o n   t h e   c o n t r o l   s o u r c e   f i e l d . 
 
                 s t r F i e l d   =   " [ "   &   c t l . C o n t r o l S o u r c e   &   " ] " 
 
         E n d   I f 
 
         
 
         I f   s t r F i e l d   < >   v b N u l l S t r i n g   T h e n 
 
                 G e t F i l t e r F i e l d   =   s t r F i e l d 
 
         E l s e I f   N o t   b C a n c e l   T h e n 
 
                 G e t F i l t e r F i e l d   =   " [ "   &   c t l . C o n t r o l S o u r c e   &   " ] " 
 
         E n d   I f 
 
         S e t   r s   =   N o t h i n g 
 
 
 
 E x i t _ H a n d l e r : 
 
         E x i t   F u n c t i o n 
 
 
 
 E r r _ H a n d l e r : 
 
         C a l l   L o g E r r o r ( E r r . N u m b e r ,   E r r . D e s c r i p t i o n ,   c o n M o d   &   " . G e t F i l t e r F i e l d " ) 
 
         R e s u m e   E x i t _ H a n d l e r 
 
 E n d   F u n c t i o n 
 
 
 
 P r i v a t e   F u n c t i o n   F i r s t V i s i b l e C o l u m n ( c b o   A s   C o m b o B o x )   A s   I n t e g e r 
 
 O n   E r r o r   G o T o   E r r _ H a n d l e r 
 
         ' P u r p o s e :       R e t u r n   t h e   c o l u m n   n u m b e r   o f   t h e   f i r s t   v i s i b l e   c o l u m n   i n   a   c o m b o . 
 
         ' R e t u r n :         C o l u m n   n u m b e r .   Z E R O - B A S E D ! 
 
         ' A r g u m e n t :     T h e   c o m b o   t o   e x a m i n e . 
 
         ' N o t e :             A l s o   r e t u r n s   z e r o   o n   e r r o r . 
 
         D i m   i   A s   I n t e g e r                         ' L o o p   c o n t r o l l e r . 
 
         D i m   v a r A r r a y   A s   V a r i a n t           ' A r r a y   o f   t h e   c o m b o ' s   C o l u m n W i d t h s   v a l u e s . 
 
         D i m   i R e s u l t   A s   I n t e g e r             ' C o l u m   n u m b e r   t o   r e t u r n . 
 
         D i m   b F o u n d   A s   B o o l e a n               ' F l a g   t h a t   w e   f o u n d   a   v a l u e   t o   r e t u r n . 
 
         
 
         I f   c b o . C o l u m n W i d t h s   =   v b N u l l S t r i n g   T h e n 
 
                 ' I f   n o   c o l u m n   w i d t h s   a r e   s p e c i f i e d ,   t h e   f i r s t   c o l u m n   i s   v i s i b l e . 
 
                 i R e s u l t   =   0 
 
                 b F o u n d   =   T r u e 
 
         E l s e 
 
                 ' P a r s e   t h e   C o l u m n W i d t h s   s t r i n g   i n t o   a n   a r r a y ,   a n d   f i n d   t h e   f i r s t   n o n - z e r o   v a l u e . 
 
                 v a r A r r a y   =   S p l i t ( c b o . C o l u m n W i d t h s ,   m s t r c S e p ) 
 
                 F o r   i   =   L B o u n d ( v a r A r r a y )   T o   U B o u n d ( v a r A r r a y ) 
 
                         I f   v a r A r r a y ( i )   < >   0   T h e n 
 
                                 i R e s u l t   =   i 
 
                                 b F o u n d   =   T r u e 
 
                                 E x i t   F o r 
 
                         E n d   I f 
 
                 N e x t 
 
                 ' I f   t h e   c o l u m n   w i d t h s   r a n   o u t   b e f o r e   a l l   c o l u m n s   w e r e   c h e c k e d ,   t h e   n e x t   c o l u m n   i s   t h e   f i r s t   v i s i b l e   o n e . 
 
                 I f   N o t   b F o u n d   T h e n 
 
                         I f   i   <   c b o . C o l u m n C o u n t   T h e n 
 
                                 i R e s u l t   =   i 
 
                                 b F o u n d   =   T r u e 
 
                         E n d   I f 
 
                 E n d   I f 
 
         E n d   I f 
 
         
 
         F i r s t V i s i b l e C o l u m n   =   i R e s u l t 
 
 
 
 E x i t _ H a n d l e r : 
 
         E x i t   F u n c t i o n 
 
 
 
 E r r _ H a n d l e r : 
 
         C a l l   L o g E r r o r ( E r r . N u m b e r ,   E r r . D e s c r i p t i o n ,   c o n M o d   &   " . F i r s t V i s i b l e C o l u m n " ) 
 
         R e s u m e   E x i t _ H a n d l e r 
 
 E n d   F u n c t i o n 
 
 
 
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 ' Y o u   m a y   p r e f e r   t o   r e p l a c e   t h i s   w i t h   a   t r u e   e r r o r   l o g g e r .   S e e   h t t p : / / a l l e n b r o w n e . c o m / s e r - 2 3 a . h t m l 
 
 P r i v a t e   F u n c t i o n   L o g E r r o r ( B y V a l   l n g E r r N u m b e r   A s   L o n g ,   B y V a l   s t r E r r D e s c r i p t i o n   A s   S t r i n g ,   _ 
 
         s t r C a l l i n g P r o c   A s   S t r i n g ,   O p t i o n a l   v P a r a m e t e r s ,   O p t i o n a l   b S h o w U s e r   A s   B o o l e a n   =   T r u e )   A s   B o o l e a n 
 
 O n   E r r o r   G o T o   E r r _ L o g E r r o r 
 
         '   P u r p o s e :   G e n e r i c   e r r o r   h a n d l e r . 
 
         '   A r g u m e n t s :   l n g E r r N u m b e r   -   v a l u e   o f   E r r . N u m b e r 
 
         '   s t r E r r D e s c r i p t i o n   -   v a l u e   o f   E r r . D e s c r i p t i o n 
 
         '   s t r C a l l i n g P r o c   -   n a m e   o f   s u b | f u n c t i o n   t h a t   g e n e r a t e d   t h e   e r r o r . 
 
         '   v P a r a m e t e r s   -   o p t i o n a l   s t r i n g :   L i s t   o f   p a r a m e t e r s   t o   r e c o r d . 
 
         '   b S h o w U s e r   -   o p t i o n a l   b o o l e a n :   I f   F a l s e ,   s u p p r e s s e s   d i s p l a y . 
 
         '   A u t h o r :   A l l e n   B r o w n e ,   a l l e n @ a l l e n b r o w n e . c o m 
 
 
 
         D i m   s t r M s g   A s   S t r i n g             '   S t r i n g   f o r   d i s p l a y   i n   M s g B o x 
 
 
 
         S e l e c t   C a s e   l n g E r r N u m b e r 
 
         C a s e   0 
 
                 D e b u g . P r i n t   s t r C a l l i n g P r o c   &   "   c a l l e d   e r r o r   0 . " 
 
         C a s e   2 5 0 1                                 '   C a n c e l l e d 
 
                 ' D o   n o t h i n g . 
 
         C a s e   3 3 1 4 ,   2 1 0 1 ,   2 1 1 5         '   C a n ' t   s a v e . 
 
                 I f   b S h o w U s e r   T h e n 
 
                         s t r M s g   =   " R e c o r d   c a n n o t   b e   s a v e d   a t   t h i s   t i m e . "   &   v b C r L f   &   _ 
 
                                 " C o m p l e t e   t h e   e n t r y ,   o r   p r e s s   < E s c >   t o   u n d o . " 
 
                         M s g B o x   s t r M s g ,   v b E x c l a m a t i o n ,   s t r C a l l i n g P r o c 
 
                 E n d   I f 
 
         C a s e   E l s e 
 
                 I f   b S h o w U s e r   T h e n 
 
                         s t r M s g   =   " E r r o r   "   &   l n g E r r N u m b e r   &   " :   "   &   s t r E r r D e s c r i p t i o n 
 
                         M s g B o x   s t r M s g ,   v b E x c l a m a t i o n ,   s t r C a l l i n g P r o c 
 
                 E n d   I f 
 
                 L o g E r r o r   =   T r u e 
 
         E n d   S e l e c t 
 
 
 
 E x i t _ L o g E r r o r : 
 
         E x i t   F u n c t i o n 
 
 
 
 E r r _ L o g E r r o r : 
 
         s t r M s g   =   " A n   u n e x p e c t e d   s i t u a t i o n   a r o s e   i n   y o u r   p r o g r a m . "   &   v b C r L f   &   _ 
 
                 " P l e a s e   w r i t e   d o w n   t h e   f o l l o w i n g   d e t a i l s : "   &   v b C r L f   &   v b C r L f   &   _ 
 
                 " C a l l i n g   P r o c :   "   &   s t r C a l l i n g P r o c   &   v b C r L f   &   _ 
 
                 " E r r o r   N u m b e r   "   &   l n g E r r N u m b e r   &   v b C r L f   &   s t r E r r D e s c r i p t i o n   &   v b C r L f   &   v b C r L f   &   _ 
 
                 " U n a b l e   t o   r e c o r d   b e c a u s e   E r r o r   "   &   E r r . N u m b e r   &   v b C r L f   &   E r r . D e s c r i p t i o n 
 
         M s g B o x   s t r M s g ,   v b C r i t i c a l ,   " L o g E r r o r ( ) " 
 
         R e s u m e   E x i t _ L o g E r r o r 
 
 E n d   F u n c t i o n 
 
 
 
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 ' R e p l a c e ( )   a n d   S p l i t ( )   a r e   n e e d e d   f o r   A c c e s s   9 7   o n l y .   L e a v e   t h e m   c o m m e n t e d   o u t   f o r   l a t e r   v e r s i o n s . 
 
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 ' P r i v a t e   F u n c t i o n   R e p l a c e ( s t r E x p r   A s   S t r i n g ,   s t r F i n d   A s   S t r i n g ,   s t r R e p l a c e   A s   S t r i n g ,   O p t i o n a l   l n g S t a r t   A s   L o n g   =   1 )   A s   S t r i n g 
 
 '         D i m   s t r O u t   A s   S t r i n g 
 
 '         D i m   l n g L e n E x p r   A s   L o n g 
 
 '         D i m   l n g L e n F i n d   A s   L o n g 
 
 '         D i m   l n g   A s   L o n g 
 
 ' 
 
 '         l n g L e n E x p r   =   L e n ( s t r E x p r ) 
 
 '         l n g L e n F i n d   =   L e n ( s t r F i n d ) 
 
 ' 
 
 '         I f   ( l n g L e n E x p r   >   0 & )   A n d   ( l n g L e n F i n d   >   0 & )   A n d   ( l n g L e n E x p r   > =   l n g S t a r t )   T h e n 
 
 '                 l n g   =   l n g S t a r t 
 
 '                 I f   l n g   >   1   T h e n 
 
 '                         s t r O u t   =   L e f t $ ( s t r E x p r ,   l n g   -   1 & ) 
 
 '                 E n d   I f 
 
 '                 D o   W h i l e   l n g   < =   l n g L e n E x p r 
 
 '                         I f   M i d ( s t r E x p r ,   l n g ,   l n g L e n F i n d )   =   s t r F i n d   T h e n 
 
 '                                 s t r O u t   =   s t r O u t   &   s t r R e p l a c e 
 
 '                                 l n g   =   l n g   +   l n g L e n F i n d 
 
 '                         E l s e 
 
 '                                 s t r O u t   =   s t r O u t   &   M i d ( s t r E x p r ,   l n g ,   1 & ) 
 
 '                                 l n g   =   l n g   +   1 
 
 '                         E n d   I f 
 
 '                 L o o p 
 
 '                 R e p l a c e   =   s t r O u t 
 
 '         E n d   I f 
 
 ' 
 
 ' E n d   F u n c t i o n 
 
 ' 
 
 ' P r i v a t e   F u n c t i o n   S p l i t ( s t r I n   A s   S t r i n g ,   s t r D e l i m   A s   S t r i n g )   A s   V a r i a n t 
 
 '         ' P u r p o s e :       R e t u r n   a   v a r i a n t   a r r a y   f r o m   t h e   i t e m s   i n   t h e   s t r i n g ,   d e l i m i t e d   t h e   2 n d   a r g u m e n t . 
 
 '         D i m   v a r A r r a y   A s   V a r i a n t           ' V a r i a n t   a r r a y   f o r   o u t p u t . 
 
 '         D i m   l n g S t a r t   A s   L o n g                 ' P o s i t i o n   i n   s t r i n g   w h e r e   a r g u m e n t   s t a r t s . 
 
 '         D i m   l n g E n d   A s   L o n g                     ' P o s i t i o n   i n   s t r i n g   w h e r e   a r g u m e n t   e n d s . 
 
 '         D i m   l n g L e n D e l i m   A s   L o n g           ' L e n g t h   o f   t h e   d e l i m i t e r   s t r i n g . 
 
 '         D i m   i   A s   I n t e g e r                         ' i n d e x   t o   t h e   a r r a y . 
 
 ' 
 
 '         l n g L e n D e l i m   =   L e n ( s t r D e l i m ) 
 
 '         I f   ( l n g L e n D e l i m   =   0 & )   O r   ( L e n ( s t r I n )   =   0 & )   T h e n 
 
 '                 R e D i m   v a r A r r a y ( 0 )               ' I n i t i a l i z e   a   z e r o - i t e m   a r r a y . 
 
 '         E l s e 
 
 '                 R e D i m   v a r A r r a y ( 9 )               ' I n i t i a l i z e   a   1 0   i t e m   a r r a y . 
 
 '                 i   =   - 1                                     ' F i r s t   i t e m   w i l l   b e   z e r o   w h e n   w e   a d d   1 . 
 
 '                 l n g S t a r t   =   1                         ' S t a r t   s e a r c h i n g   a t   f i r s t   c h a r a c t e r   o f   s t r i n g . 
 
 ' 
 
 '                 ' S e a r c h   f o r   t h e   d e l i m i t e r   i n   t h e   i n p u t   s t r i n g ,   u n t i l   n o t   f o u n d   a n y   m o r e . 
 
 '                 D o 
 
 '                         i   =   i   +   1 
 
 '                         I f   i   >   U B o u n d ( v a r A r r a y )   T h e n         ' A d d   m o r e   i t e m s   i f   n e c e s s a r y 
 
 '                                 R e D i m   P r e s e r v e   v a r A r r a y ( U B o u n d ( v a r A r r a y )   +   1 0 ) 
 
 '                         E n d   I f 
 
 ' 
 
 '                         l n g E n d   =   I n S t r ( l n g S t a r t ,   s t r I n ,   s t r D e l i m ) 
 
 '                         I f   l n g E n d   =   0   T h e n     ' T h i s   i s   t h e   l a s t   i t e m . 
 
 '                                 v a r A r r a y ( i )   =   T r i m ( M i d ( s t r I n ,   l n g S t a r t ) ) 
 
 '                                 E x i t   D o 
 
 '                         E l s e 
 
 '                                 v a r A r r a y ( i )   =   T r i m ( M i d ( s t r I n ,   l n g S t a r t ,   l n g E n d   -   l n g S t a r t ) ) 
 
 '                                 l n g S t a r t   =   l n g E n d   +   l n g L e n D e l i m 
 
 '                         E n d   I f 
 
 '                 L o o p 
 
 '                 ' S e t   t h e   u p p e r   b o u n d   o f   t h e   a r r a y   t o   t h e   c o r r e c t   n u m b e r   o f   i t e m s . 
 
 '                 R e D i m   P r e s e r v e   v a r A r r a y ( i ) 
 
 '         E n d   I f 
 
 ' 
 
 '         S p l i t   =   v a r A r r a y 
 
 ' E n d   F u n c t i o n 
 
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 
 
 
 
 